/*
 * @Author       : tfhappy
 * @Date         : 2020-07-09 00:32:48
 * @LastEditTime : 2020-07-10 00:19:57
 * @FilePath     : /giteecli/action/common.go
 * @Description  :
 */
package action

import (
	"gitee.com/tfhappy/giteecli/api"
	"gitee.com/tfhappy/giteecli/common"
	"github.com/urfave/cli/v2"
)

func GetAuthToken(c *cli.Context) string {

	authRequest := &api.AuthRequest{
		Username:     c.String(common.ACCOUNT),
		Password:     c.String(common.PASSWORD),
		ClientID:     c.String(common.CLIENTID),
		ClientSecret: c.String(common.CLIENTSECRET),
	}
	authInfo, err := api.GetAuthInfo(authRequest)
	common.PanicError(err)
	return authInfo.AccessToken
}
